
<html style="width: 100%">
<head >
    <title>Title</title>

</head>
<!--
      这个页面进行审批流程的展示，并且让审批人进行审批，可以选择驳回或者通过，并且填入意见
-->
<script src="/approval/static/js/jquery-3.4.1.min.js"></script>
<script src="/approval/static/js/vue-2.4.0.js"></script>
<link type="text/css" rel="stylesheet" href="/approval/static/css/bootstrap.min.css"/>
<script>

       var draw=function (){
           var c=document.getElementsByTagName("canvas");
           for(var s in c){
               var ctx=c[s].getContext("2d");
               ctx.strokeStyle="#33e3f0";
               ctx.moveTo(25,0);
               ctx.lineTo(25,50);

               ctx.moveTo(10,35);
               ctx.lineTo(25,50);
               ctx.moveTo(40,35);
               ctx.lineTo(25,50);
               ctx.stroke();
           }
       }
       var getApprovalDetail=function (){
           var recordno=sessionStorage.getItem("recordno");
           var account=sessionStorage.getItem("account");
           var res=null;
           $.ajax({
               url:"/approval/records/getFinish?recordno="+recordno,
               dataType:"json",
               async:false,
               success:function (response){
                   res=response;
               }

           })
           return res;

       }
       $(document).ready(function (){
            var res=getApprovalDetail();
            var recordno1=sessionStorage.getItem("recordno");
            var approvalno=sessionStorage.getItem("account");
            var random=Math.random()*10000;
            var app=new Vue({
                el:"#app",
                data:{
                    records:res,
                    opinion:"",
                    recordno:recordno1,
                    approvalno:approvalno

                },
                methods:{
                    bt_refuse:function (){
                        alert("拒绝按钮被点击");
                        if (this.opinion==""){
                            alert("请输入意见");
                        }else {
                            var js={recordno:this.recordno,
                                recordopinion1:this.opinion,
                                approvalno:this.approvalno
                            }
                            alert("当前账户"+approvalno)
                            $.ajax({
                                url:"/approval/records/refuse?random="+random,
                                type:"POST",
                                data: js,
                                dataType: "text",
                                success:function (response){
                                    if (response=="true"){
                                        alert("审批成功");
                                    }else {
                                        alert("审批失败");

                                    }
                                    window.location="/approval/static/html/ApprovalDetail.html";
                                }
                            })
                        }

                    },
                    bt_agree:function (){

                        if (this.opinion==""){
                            alert("请输入意见");
                        }else {
                            var js={recordno:this.recordno,
                                recordopinion1:this.opinion
                            }
                            $.ajax({
                                url:"/approval/records/agree?random="+random,
                                type:"POST",
                                data: js,
                                dataType: "text",
                                success:function (response){
                                    if (response=="true"){
                                        alert("审批成功");
                                    }else {
                                        alert("审批失败");

                                    }
                                    window.location="/approval/static/html/ApprovalDetail.html";
                                }
                            })
                        }

                    },
                }

            })
           draw();
       })

</script>
<body style="width: 100%">


    <div id="app" class="container" style=" height: 200%; width: 60%;margin-left: 20%;">
        <form action="/approvalProcess/approval" id="content">
            <div class="panel panel-default" style="padding: 0px;">

                <div class="panel-body">
                    <div class="panel panel-default" style="padding: 0px;margin: 0px;">
                        <div class="panel-body" style="padding: 0px">
                            <div>申请人：{{records[0].staffno}}</div>
                            <div >审批名称：{{records[0].recordname}}</div>
                            <div >申请理由：{{records[0].recordopinion}}</div>
                        </div>
                    </div >
                    <canvas  name="canvas" width="50" height="50" style="margin-left: 45%"> </canvas>
                    <div v-for="record in records" v-if="records[0].finished=='1'">
                    <div class="panel panel-default" style="padding: 0px;margin: 0px;">
                        <div class="panel-body" style="padding: 0px">
                            <div class="text-success" style="color: #499C54">审批人：{{record.approvalno}}</div>
                            <div class="text-success" style="color: #499C54">审批意见：{{record.recordopinion1}}</div>
                            <div class="text-success" style="color: #499C54">已经同意</div>
                        </div>
                    </div>
                    <canvas  name="canvas" width="50" height="50" style="margin-left: 45%"> </canvas>
                    </div>
                    <div class="panel panel-default" style="padding: 0px;margin: 0px;">
                        <div class="panel-body" style="padding: 0px">
                            <textarea class="form-control" rows="3" v-model="opinion"></textarea>
                            <button type="button" class="btn btn-success" @click="bt_agree">同意</button>
                            <button type="button" class="btn btn-danger" @click="bt_refuse">拒绝</button>
                        </div>
                    </div>

                </div>
            </div>


        </form>



</div>


</body>
</html>
